/*******************************************************************************
 * Copyright (c) 2013 Zero Square LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Zero Square LLC. Version 1
 * which accompanies this distribution
 ******************************************************************************/
package com.zsqr.dashboard.primefaces;

import java.io.Serializable;  
import java.util.ArrayList;  
import java.util.List;  
import java.util.UUID;  
import com.zsqr.dashboard.primefaces.Car;

public class TableBean implements Serializable {  
	  
	 
	private static final long serialVersionUID = -7897071115401970741L;

	private final static String[] colors;  
	  
	 private final static String[] manufacturers;  
	  
	 private List<Car> carsSmall;  
  
	
	 

	static {  
        colors = new String[10];  
        colors[0] = "Black";  
        colors[1] = "White";  
        colors[2] = "Green";  
        colors[3] = "Red";  
        colors[4] = "Blue";  
        colors[5] = "Orange";  
        colors[6] = "Silver";  
        colors[7] = "Yellow";  
        colors[8] = "Brown";  
        colors[9] = "Maroon";  
  
        manufacturers = new String[10];  
        manufacturers[0] = "Mercedes";  
        manufacturers[1] = "BMW";  
        manufacturers[2] = "Volvo";  
        manufacturers[3] = "Audi";  
        manufacturers[4] = "Renault";  
        manufacturers[5] = "Opel";  
        manufacturers[6] = "Volkswagen";  
        manufacturers[7] = "Chrysler";  
        manufacturers[8] = "Ferrari";  
        manufacturers[9] = "Ford";  
    }  
  
   
  
    public TableBean() {  
        carsSmall = new ArrayList<Car>();  
  
        populateRandomCars(carsSmall, 25);  
    }  
  
    private void populateRandomCars(List<Car> list, int size) {  
        for(int i = 0 ; i < size ; i++)  
            list.add(new Car(getRandomModel(),  getRandomManufacturer(), getRandomYear(), getRandomColor()));  
    }  
   
    public List<Car> populateCarList(int size){
    	List<Car> list = new ArrayList<Car>();
    	for(int i = 0 ; i < size ; i++)  
            list.add(new Car(getRandomModel(),  getRandomManufacturer(), getRandomYear(), getRandomColor()));
    	return list;
    }
    //public static List<Car> getCarsSmall() {  
    	//TableBean tableBean = new TableBean();
    //	return  tableBean.populateCarList(9);
   // }  
  
    private int getRandomYear() {  
        return (int) (Math.random() * 50 + 1960);  
    }  
  
    private String getRandomColor() {  
        return colors[(int) (Math.random() * 9)];  
    }  
  
    private String getRandomManufacturer() {  
        return manufacturers[(int) (Math.random() * 9)];  
    }  
  
    private String getRandomModel() {  
        return UUID.randomUUID().toString().substring(0,8);  
    }

	public List<Car> getCarsSmall() {
		return carsSmall;
	}

	public void setCarsSmall(List<Car> carsSmall) {
		this.carsSmall = carsSmall;
	}

    
    
}

